import ready from "../../script/base.js";
import createTd3 from "../../script/module/td3.js";
import createPlayer from "../../script/module/music.163.player.js";
import createRadio from "../../script/module/radio.js";
import Board from "../../script/module/board.js";

ready(
  () => {
    console.log("interactive");
    const td3 = createTd3(); // 创建第三列

    const img = document.createElement("img");
    img.style = "width: 100%";
    img.src = new URL("./qrcode_1667398431005_看图王.png", import.meta.url).href;
    td3.appendChild(img);

    const radio = createRadio();
    radio.onclick = () => {
      const player = createPlayer(7717337585, true); // 创建网易云音乐播放器
      td3.prepend(player); // 添加网易云播放器到第三列中
      const animation = radio.querySelector(".radio-svg").animate(
        [
          { transform: "rotate(0) scale(1)", opacity: 1 },
          { transform: "rotate(360deg) scale(0)", opacity: 0 },
        ],
        {
          duration: 1000,
          iterations: 1,
        }
      );
      animation.addEventListener("finish", () => {
        radio.remove();
      });
    };
    document.body.appendChild(radio);
  },
  () => {
    console.log("complete");
    const board = new Board(); // 创建留言板包装类
    board
      .setBoardWelcomeText("hi，欢迎留言！QQ：2326606134")
      .installBoardFilter(() => {
        alert("少说脏话");
      });
  }
);
